package com.example.commons.utils;

import com.github.pagehelper.PageHelper;

import com.example.commons.utils.PageResult;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class MyPageHelper {

        public static void startPage(PageResult pageResult) {
            PageHelper.startPage(pageResult.getPageNum(),pageResult.getPageSize());

        }


        public static  PageResult getPageResult(List content){

            PageInfo pageInfo = new PageInfo(content);

            PageResult pageResult = new PageResult();

            pageResult.setTotal(pageInfo.getTotal());
            pageResult.setContent(pageInfo.getList());
            pageResult.setPages(pageInfo.getPages());
            pageResult.setPageSize(pageInfo.getPageSize());
            pageResult.setPageNum(pageInfo.getPageNum());

            return pageResult;
        }
}
